package com.qf.mapper;

import com.qf.model.Project;
import com.qf.model.Stage;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface StageMapper {
    @Results(id = "stageMap",value = {
            @Result(column = "sid",property = "sid"),
            @Result(column = "sname",property = "sname"),
            @Result(column = "starttime",property ="starttime"),
            @Result(column = "endtime",property ="endtime"),
            @Result(column = "updatetime",property ="updatetime"),
            @Result(column = "pid",property = "pid"),
            @Result(column = "pid",property ="project",javaType = Project.class,one=
            @One(select = "com.qf.mapper.ProjectMapper.selectByPid" ,fetchType = FetchType.EAGER)
            )
    })

    @Select("Select * from stage where status =1 limit #{currentPage},#{pageSize}")
    List<Stage> findPage(@Param("currentPage") int currentPage, @Param("pageSize") Integer pageSize);
    @Select("select count(*) from stage where status=1")
    Long count();
    @Select("select * from stage where status =1")
    List<Stage> selectAll();
}
